/**
 * File              : common.h
 * Author            : Major Lin <mingjie.lin@nxp.com>
 * Date              : 01.08.2019
 * Last Modified Date: 01.08.2019
 * Last Modified By  : Major Lin <mingjie.lin@nxp.com>
 */

//
//  Copyright (c) 2012-2013 Andrew Payne <andy@payne.org>
//
#ifndef __COMMON_H_
#define __COMMON_H_

#include <stdint.h>
// Memory locations defined by the linker
extern uint32_t __heap_start[];
extern uint32_t __StackTop[];
extern uint32_t __data_start__[], __data_end__[];
extern uint32_t __bss_start__[], __bss_end__[];
extern uint32_t __etext[];                // End of code/flash

// From _startup.c
void fault(uint32_t pattern);
#define FAULT_FAST_BLINK 	(0b10101010101010101010101010101010)
#define FAULT_MEDIUM_BLINK 	(0b11110000111100001111000011110000)
#define FAULT_SLOW_BLINK 	(0b11111111000000001111111100000000)

// Interrupt enabling and disabling
void enable_irq(int n);
void disable_irq(int n);

void env_init();
// TODO:  IRQ disable

static inline void __enable_irq(void)	{ asm volatile ("cpsie i"); }
static inline void __disable_irq(void)  { asm volatile ("cpsid i"); }
#endif
